import request from '@/utils/request';
// 获取所有频道
export const getchannels=()=>{
    return request({
        method:'GET',
        url:'/v1_0/channels',
    })
}

//首页列表
export const getArticles =params=>{
    return request({
        method:'GET',
        url:'/v1_0/articles',
        params
    })
}
//首页列表详情
export const getArticleDetaile =article_id=>{
    return request({
        method:'GET',
        url:`/v1_0/articles/${article_id}`,
    })
}
//我的频道列表
export const getuserchannels =params=>{
    return request({
        method:'GET',
        url:'/v1_0/user/channels',
        params
    })
}
//删除指定用户的指定频道
export const deluserchannel=(id)=>{
    return request({
        method:'DELETE',
        url:`/v1_0/user/channels/${id}`,
    })
}
//添加指定用户指定频道
export const adduserchannel=(channels)=>{
    return request({
        method:'PATCH',
        url:'/v1_0/user/channels',
        data:{
            channels:[channels]
        }
    })
}
//对文章点赞
export const likearcitle=(target)=>{
    return request({
        method:'POST',
        url:'/v1_0/article/likings',
        data:{
            target:target
        }
    })
}

//取消对文章点赞
export const caclelikearcitle=(target)=>{
    return request({
        method:'DELETE',
        url:`/v1_0/article/likings/${target}`,
    })
}

//对文章收藏
export const collections=(target)=>{
    return request({
        method:'POST',
        url:'/v1_0/article/collections',
        data:{
            target:target
        }
    })
}
//取消对文章收藏
export const caclecollections=(target)=>{
    return request({
        method:'DELETE',
        url:`/v1_0/article/collections/${target}`,
        
    })
}
//关注作者
export const starauthor=(target)=>{
    return request({
        method:'POST',
        url:`/v1_0/user/followings`,
        data:{
            target:target
        }
    })
}

// 取消关注作者
export const caclestarauthor=(target)=>{
    return request({
        method:'DELETE',
        url:`/v1_0/user/followings/${target}`,
    })
}


//获取评论

export const getcomment=(params)=>{
    return request({
        method:'GET',
        url:`/v1_0/comments`,
        params
    })
}

// 对评论点赞

export const commentlikings=(data)=>{
    return request({
        method:'POST',
        url:`/v1_0/comment/likings`,
        data
    })
}
//取消点赞

export const commentdellikings=(target)=>{
    return request({
        method:'DELETE',
        url:`/v1_0/comment/likings/${target}`,
    })
}

//发布评论


export const publishcom=(data)=>{
    return request({
        method:'POST',
        url:`/v1_0/comments`,
        data
    })
}